//
//  StatusCellBottomView.swift
//  Weobo
//
//  Created by 史亚洲 on 16/1/19.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class StatusCellBottomView: UIView {
    @objc private func commentBtnClick() {
        
        let temp = TempViewController()
        //temp.hidesBottomBarWhenPushed = true
        
        //在页面跳转中,使用的频率比较高,可以代替到部分的协议代理,block
        navController()?.pushViewController(temp, animated: true)

    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //MARK:2.设置UI界面,设置约束
    private func setupUI() {
        backgroundColor=UIColor.randomColor()
        addSubview(retweetedBtn)
        addSubview(commentBtn)
        addSubview(likeBtn)
        
        /*
        三等分这个视图
        左右都应该设置约束条件
        设置宽度相等
        设置约束
        */
        
        retweetedBtn.snp_makeConstraints { (make) -> Void in
            make.left.top.bottom.equalTo(self)
        }
        
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedBtn.snp_right)
            make.width.equalTo(retweetedBtn.snp_width)
            make.bottom.top.equalTo(self)
        }
        
        likeBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.bottom.top.equalTo(self)
            make.right.equalTo(self.snp_right)
            make.width.equalTo(commentBtn.snp_width)
        }
    
        
        let sepView1=lineView()
        let sepView2=lineView()
        
        addSubview(sepView1)
        addSubview(sepView2)
        
        let w: CGFloat = 0.5
        let scale: CGFloat = 0.4
        
        
        sepView1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedBtn.snp_right)
            make.centerY.equalTo(self.snp_centerY)
            make.height.equalTo(self.snp_height).multipliedBy(scale)
            make.width.equalTo(w)
            
        }
        sepView2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.centerY.equalTo(self.snp_centerY)
            make.height.equalTo(self.snp_height).multipliedBy(scale)
            make.width.equalTo(w)
        }
    commentBtn.addTarget(self, action: "commentBtnClick", forControlEvents: .TouchUpInside)
    
    
    
    }
    private func lineView() -> UIView {
        let v = UIView()
        
        v.backgroundColor=UIColor.lightGrayColor()
        return v
    
    
    }
    
    //MARK:1.懒加载所有的子视图
    
    //1.转发
    private lazy var retweetedBtn: UIButton = UIButton(title: "转发", color: UIColor.darkGrayColor(), fontSize: 10, backImageName: nil,imageName: "timeline_icon_retweet")

    //2.评论
    private lazy var commentBtn: UIButton = UIButton(title: "评论", color: UIColor.darkGrayColor(), fontSize: 10, backImageName: nil, imageName: "timeline_icon_comment")
    
    //3.点赞
    private lazy var likeBtn: UIButton = UIButton(title: "点赞", color: UIColor.darkGrayColor(), fontSize: 10, backImageName: nil, imageName: "timeline_icon_unlike")
}
